﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using TR0217.ControlEx;
using System.Runtime.InteropServices;
using System.Drawing.Drawing2D;
using TR0217.AboutToAdd;

namespace WindowsApplication1
{
    public partial class MainForm : Form
    {
        ContextContainer _contextContainer;

        public MainForm()
        {
            InitializeComponent();
            _contextContainer = new ContextContainer(new UserControl1());
            _contextContainer.ContextMode = ContextMode.MultiSelect;
            ComboBoxExItem item = new ComboBoxExItem();
            item.Text = "nihhoa";
            item.ImageIndex = 0;
            item.Level = 1;
            cboValue.Items.Add(item);
            cboiStrip.Items.Add(item);
            item = new ComboBoxExItem();
            item.Text = "gfdgsfd";
            item.Level = 1;
            cboValue.Items.Add(item);
            cboiStrip.Items.Add(item);
        }

        private CenterLayoutEngine layoutEngine;
        public override System.Windows.Forms.Layout.LayoutEngine LayoutEngine
        {
            get
            {
                if (layoutEngine == null)
                {
                    layoutEngine = new CenterLayoutEngine(this,base.LayoutEngine);
                }

                return layoutEngine;
            }
        }

        private void tsmiToo1_Click(object sender, EventArgs e)
        {
            toolStrip1.Visible = tsmiToo1.Checked;
        }

        private void tsmiToo2_Click(object sender, EventArgs e)
        {
            toolStrip2.Visible = tsmiToo2.Checked;
        }


        private void toolStrip2_VisibleChanged(object sender, EventArgs e)
        {
            tsmiToo2.Checked = toolStrip2.Visible;
        }

        private void toolStripButton36_Click(object sender, EventArgs e)
        {
            MessageBox.Show("你好");
        }

        private void toolStrip1_VisibleChanged(object sender, EventArgs e)
        {
            tsmiToo1.Checked = toolStrip1.Visible;
        }

        private void splitButton1_SplitMouseClick(object sender, MouseEventArgs e)
        {
            _contextContainer.Show(splitButton1);
        }

        //[DllImport("user32.dll")]
        //private static extern IntPtr GetWindowDC(IntPtr hWnd);
        //[DllImport("user32.dll")]
        //private static extern int ReleaseDC(IntPtr hWnd, IntPtr hDC);

        //private const int WM_NCPAINT = 0x0085;
        //private const int WM_NCACTIVATE = 0x0086;
        //private const int WM_NCLBUTTONDOWN = 0x00A1;
        //protected override void WndProc(ref Message m)
        //{
        //    base.WndProc(ref m);
        //    Rectangle vRectangle = new Rectangle((Width - 75) / 2, 3, 75, 25);
        //    switch (m.Msg)
        //    {
        //        case WM_NCPAINT:
        //        case WM_NCACTIVATE:
        //            IntPtr vHandle = GetWindowDC(m.HWnd);
        //            Graphics vGraphics = Graphics.FromHdc(vHandle);
        //            vGraphics.FillRectangle(new LinearGradientBrush(vRectangle,
        //                Color.Pink, Color.Purple, LinearGradientMode.BackwardDiagonal),
        //                vRectangle);

        //            StringFormat vStringFormat = new StringFormat();
        //            vStringFormat.Alignment = StringAlignment.Center;
        //            vStringFormat.LineAlignment = StringAlignment.Center;
        //            vGraphics.DrawString("About", Font, Brushes.BlanchedAlmond,
        //                vRectangle, vStringFormat);

        //            vGraphics.Dispose();
        //            ReleaseDC(m.HWnd, vHandle);
        //            break;
        //        case WM_NCLBUTTONDOWN:
        //            Point vPoint = new Point((int)m.LParam);
        //            vPoint.Offset(-Left, -Top);
        //            if (vRectangle.Contains(vPoint))
        //                MessageBox.Show(vPoint.ToString());
        //            break;
        //    }
        //}


        private void dateTimePicker1_ValueChanged(object sender, EventArgs e)
        {

        }

        private void radioButton1_CheckedChanged(object sender, EventArgs e)
        {

        }

        private void button1_Click(object sender, EventArgs e)
        {
            Color c = colorComboBox1.SelectedColor;
        }

        private void MainForm_Load(object sender, EventArgs e)
        {
            for(int i = 0 ; i < 10; i ++ )
            {                
                colorComboBox1.Items.Add(new ColorComboBoxItem(ColorManager.GetGradientColor(i, 10,Color.Blue,Color.Red,Color.Yellow)));
            }
        }


        private void MainForm_Layout(object sender, LayoutEventArgs e)
        {

        }

        private void toolStrip2_ItemClicked(object sender, ToolStripItemClickedEventArgs e)
        {

        }

    }
}
